home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume17 / mgr / part39 < prev    next >
Encoding:
Internet Message Format  |  1989-01-19  |  37.7 KB

  1. Subject:  v17i040:  MGR, Bellcore window manager, Part39/61
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: Stephen A. Uhler <sau@bellcore.com>
  6. Posting-number: Volume 17, Issue 40
  7. Archive-name: mgr/part39
  8.  
  9.  
  10.  
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 39 (of 61)."
  19. # Contents:  lib/sfont.c src/subs.c
  20. # Wrapped by rsalz@papaya.bbn.com on Thu Nov 17 21:05:48 1988
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'lib/sfont.c' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'lib/sfont.c'\"
  24. else
  25. echo shar: Extracting \"'lib/sfont.c'\" \(18800 characters\)
  26. sed "s/^X//" >'lib/sfont.c' <<'END_OF_FILE'
  27. X/*                        Copyright (c) 1987 Bellcore
  28. X *                            All Rights Reserved
  29. X *       Permission is granted to copy or use this program, EXCEPT that it
  30. X *       may not be sold for profit, the copyright notice must be reproduced
  31. X *       on copies, and credit should be given to Bellcore where it is due.
  32. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  33. X */
  34. X/*    $Header: sfont.c,v 4.2 88/06/22 09:12:40 sau Exp $
  35. X    $Source: /tmp/mgrsrc/lib/RCS/sfont.c,v $
  36. X*/
  37. Xstatic char    RCSid_[] = "$Source: /tmp/mgrsrc/lib/RCS/sfont.c,v $$Revision: 4.2 $";
  38. X
  39. X/* These characters were adapted from the Hershey font collection.
  40. X *
  41. X *   The Hershey Fonts were originally created by Dr. A. V. Hershey
  42. X *   while working at the U. S.  National Bureau of Standards.
  43. X */
  44. X
  45. X/*---------------------------------------*/
  46. Xsfont( font, ch, min, max, npts, pts)
  47. X    int font, *npts;
  48. X    char ch;
  49. X    short    *min, *max, *pts;
  50. X#    define char_per_font 96
  51. X{
  52. X    int i;   char *c;
  53. Xstatic char error_char[127] = { 62, -11, 11,
  54. X        -2,4,0,4,0,5,-1,6,-2,5,-2,4,-2,2,-3,0,-2,-2,-3,-4,
  55. X        -3,-7,-2,-9,0,-10,2,-9,3,-7,3,-4,2,-2,3,0,2,2,2,4,
  56. X        2,5,1,6,0,5,0,4,2,4,31,31,-4,10,-5,5,-2,2,-3,1,-7,3,
  57. X        -12,0,31,31,-10,-5,-7,0,-3,0,-3,-1,-6,-3,-5,-10,31,31,
  58. X        4,10,5,5,2,2,3,1,7,3,12,0,31,31,10,-5,7,0,3,0,3,-1,
  59. X        6,-3,5,-10,31,31,-2,-7,1,-7,2,-6,1,-5,-1,-5,-2,-4,
  60. X        -1,-3,2,-3 };
  61. X
  62. X/*--  Stick Figure Font --*/
  63. X
  64. Xstatic char c1[] = {                /* SP */
  65. X     0, -8,  8};
  66. Xstatic char c2[] = {
  67. X     8,  -4,   4,
  68. X     0,  10,   0,  -2,
  69. X    31,  31,   0,  -7,  -1,  -8,   0,  -9,   1,  -8,
  70. X     0,  -7};
  71. Xstatic char c3[] = {
  72. X     5,  -7,   7,
  73. X    -2,  12,  -4,   5,
  74. X    31,  31,   4,  12,   2,   5};
  75. Xstatic char c4[] = {
  76. X    11, -10,  11,
  77. X     1,  12,  -6, -16,  31,  31,
  78. X     7,  12,   0, -16,  31,  31,  -6,   1,   8,   1,
  79. X    31,  31,  -7,  -5,   7,  -5};
  80. Xstatic char c5[] = {
  81. X      26, -10,  10,
  82. X    -2,  16,  -2, -13,  31,  31,
  83. X     2,  16,   2, -13,  31,  31,
  84. X     7,   9,   5,  11,   2,  12,
  85. X    -2,  12,  -5,  11,  -7,   9,  -7,   7,  -6,   5,
  86. X    -5,   4,  -3,   3,   3,   1,   5,   0,   6,  -1,
  87. X     7,  -3,   7,  -6,   5,  -8,   2,  -9,  -2,  -9,
  88. X    -5,  -8,  -7,  -6};
  89. Xstatic char c6[] = {
  90. X      31, -12,  12,
  91. X     9,  12,  -9,  -9,  31,  31,
  92. X    -4,  12,  -2,  10,  -2,   8,  -3,   6,  -5,   5,
  93. X    -7,   5,  -9,   7,  -9,   9,  -8,  11,  -6,  12,
  94. X    -4,  12,  -2,  11,   1,  10,   4,  10,   7,  11,
  95. X     9,  12,  31,  31,   5,  -2,   3,  -3,   2,  -5,
  96. X     2,  -7,   4,  -9,   6,  -9,   8,  -8,   9,  -6,
  97. X     9,  -4,   7,  -2,   5,  -2};
  98. X
  99. Xstatic char c7[] = {
  100. X      30, -12,  13,
  101. X    10,   4,   9,   5,   8,   5,   7,   4,
  102. X     6,   2,   4,  -4,   3,  -6,   1,  -8,  -1,  -9,
  103. X    -5,  -9,  -8,  -8,  -9,  -6,  -9,  -3,  -8,  -1,
  104. X    -2,   3,   0,   5,   1,   7,   1,   9,   0,  11,
  105. X    -2,  12,  -4,  11,  -5,   9,  -5,   7,  -4,   4,
  106. X    -2,   1,   3,  -6,   5,  -8,   8,  -9,   9,  -9,
  107. X    10,  -8};
  108. X
  109. Xstatic char c8[] = {
  110. X       2,  -4,   4,
  111. X     1,  12,  -1,   5};
  112. X
  113. Xstatic char c9[] = {
  114. X      10,  -7,   7,
  115. X     4,  16,   2,  14,   0,  11,
  116. X    -2,   7,  -3,   2,  -3,  -2,  -2,  -7,   0, -11,
  117. X     2, -14,   4, -16};
  118. X
  119. Xstatic char c10[] = {
  120. X      10,  -7,   7,
  121. X    -4,  16,  -2,  14,   0,  11,
  122. X     2,   7,   3,   2,   3,  -2,   2,  -7,   0, -11,
  123. X    -2, -14,  -4, -16};
  124. X
  125. Xstatic char c11[] = {
  126. X       8,  -8,   8,
  127. X     0,  12,   0,   0,  31,  31,
  128. X    -5,   9,   5,   3,  31,  31,   5,   9,  -5,   3};
  129. X
  130. Xstatic char c12[] = {
  131. X       5, -12,  12,
  132. X     0,   9,   0,  -9,  31,  31,
  133. X    -9,   0,   9,   0};
  134. X
  135. Xstatic char c13[] = {
  136. X       7,  -4,   4,
  137. X     0,  -9,  -1,  -8,   0,  -7,
  138. X     1,  -8,   1, -10,   0, -12,  -1, -13};
  139. X
  140. Xstatic char c14[] = {
  141. X       2, -12,  12,
  142. X    -9,   0,   9,   0};
  143. X
  144. Xstatic char c15[] = {
  145. X       5,  -4,   4,
  146. X     0,  -7,  -1,  -8,   0,  -9,
  147. X     1,  -8,   0,  -7};
  148. X
  149. Xstatic char c16[] = {
  150. X       2, -11,  11,
  151. X     9,  16,  -9, -16};
  152. X
  153. Xstatic char c17[] = {
  154. X      17, -10,  10,
  155. X    -1,  12,  -4,  11,  -6,   8,
  156. X    -7,   3,  -7,   0,  -6,  -5,  -4,  -8,  -1,  -9,
  157. X     1,  -9,   4,  -8,   6,  -5,   7,   0,   7,   3,
  158. X     6,   8,   4,  11,   1,  12,  -1,  12};
  159. X
  160. Xstatic char c18[] = {
  161. X       4, -10,  10,
  162. X    -4,   8,  -2,   9,   1,  12,
  163. X     1,  -9};
  164. X
  165. Xstatic char c19[] = {
  166. X      14, -10,  10,
  167. X    -6,   7,  -6,   8,  -5,  10,
  168. X    -4,  11,  -2,  12,   2,  12,   4,  11,   5,  10,
  169. X     6,   8,   6,   6,   5,   4,   3,   1,  -7,  -9,
  170. X     7,  -9};
  171. X
  172. Xstatic char c20[] = {
  173. X      15, -10,  10,
  174. X    -5,  12,   6,  12,   0,   4,
  175. X     3,   4,   5,   3,   6,   2,   7,  -1,   7,  -3,
  176. X     6,  -6,   4,  -8,   1,  -9,  -2,  -9,  -5,  -8,
  177. X    -6,  -7,  -7,  -5};
  178. X
  179. Xstatic char c21[] = {
  180. X       6, -10,  10,
  181. X     3,  12,  -7,  -2,   8,  -2,
  182. X    31,  31,   3,  12,   3,  -9};
  183. X
  184. Xstatic char c22[] = {
  185. X      17, -10,  10,
  186. X     5,  12,  -5,  12,  -6,   3,
  187. X    -5,   4,  -2,   5,   1,   5,   4,   4,   6,   2,
  188. X     7,  -1,   7,  -3,   6,  -6,   4,  -8,   1,  -9,
  189. X    -2,  -9,  -5,  -8,  -6,  -7,  -7,  -5};
  190. X
  191. Xstatic char c23[] = {
  192. X      23, -10,  10,
  193. X     6,   9,   5,  11,   2,  12,
  194. X     0,  12,  -3,  11,  -5,   8,  -6,   3,  -6,  -2,
  195. X    -5,  -6,  -3,  -8,   0,  -9,   1,  -9,   4,  -8,
  196. X     6,  -6,   7,  -3,   7,  -2,   6,   1,   4,   3,
  197. X     1,   4,   0,   4,  -3,   3,  -5,   1,  -6,  -2};
  198. X
  199. Xstatic char c24[] = {
  200. X       5, -10,  10,
  201. X     7,  12,  -3,  -9,  31,  31,
  202. X    -7,  12,   7,  12};
  203. X
  204. Xstatic char c25[] = {
  205. X      29, -10,  10,
  206. X    -2,  12,  -5,  11,  -6,   9,
  207. X    -6,   7,  -5,   5,  -2,   4,   3,   3,   5,   2,
  208. X     6,   1,   7,  -1,   7,  -4,   6,  -6,   4,  -8,
  209. X     1,  -9,  -1,  -9,  -4,  -8,  -6,  -6,  -7,  -4,
  210. X    -7,  -1,  -6,   1,  -5,   2,  -3,   3,   2,   4,
  211. X     5,   5,   6,   7,   6,   9,   5,  11,   2,  12,
  212. X    -2,  12};
  213. X
  214. Xstatic char c26[] = {
  215. X      23, -10,  10,
  216. X     6,   5,   5,   2,   3,   0,
  217. X     0,  -1,  -1,  -1,  -4,   0,  -6,   2,  -7,   5,
  218. X    -7,   6,  -6,   9,  -4,  11,  -1,  12,   0,  12,
  219. X     3,  11,   5,   9,   6,   5,   6,   0,   5,  -5,
  220. X     3,  -8,   0,  -9,  -2,  -9,  -5,  -8,  -6,  -6};
  221. X
  222. Xstatic char c27[] = {
  223. X      11,  -4,   6,
  224. X     0, 5, -1, 4, 0, 3, 1, 4, 0, 5, 31, 31, 0, -7, -1, -8,
  225. X     0, -9, 1, -8, 0, -7};
  226. X
  227. Xstatic char c28[] = {
  228. X      13,  -4,   4,
  229. X     0,   5,  -1,   4,   0,   3,
  230. X     1,   4,   0,   5,  31,  31,   0,  -9,  -1,  -8,
  231. X     0,  -7,   1,  -8,   1, -10,   0, -12,  -1, -13};
  232. X
  233. Xstatic char c29[] = {
  234. X       3, -11,  11,
  235. X     8,   9,  -8,   0,   8,  -9};
  236. X
  237. Xstatic char c30[] = {
  238. X       5, -12,  12,
  239. X    -9,   3,   9,   3,  31,  31,
  240. X    -9,  -3,   9,  -3};
  241. X
  242. Xstatic char c31[] = {
  243. X       3, -11,  11,
  244. X    -8,   9,   8,   0,  -8,  -9};
  245. X
  246. Xstatic char c32[] = {
  247. X      23,  -9,   9,
  248. X    -5,   8,  -4,   7,  -5,   6,
  249. X    -6,   7,  -6,   8,  -5,  10,  -4,  11,  -2,  12,
  250. X     1,  12,   4,  11,   5,  10,   6,   8,   6,   6,
  251. X     5,   4,   4,   3,   0,   1,   0,  -2,  31,  31,
  252. X     0,  -7,  -1,  -8,
  253. X     0,  -9,   1,  -8,   0,  -7};
  254. X
  255. Xstatic char c33[] = {
  256. X      44, -13,  14,
  257. X     5,   4,   4,   6,   2,   7,
  258. X    -1,   7,  -3,   6,  -4,   5,  -5,   2,  -5,  -1,
  259. X    -4,  -3,  -2,  -4,   1,  -4,   3,  -3,   4,  -1,
  260. X    31,  31,
  261. X     6,   7,   5,   4,   4,  -1,
  262. X     4,  -3,   6,  -4,   8,  -4,  10,  -2,  11,   1,
  263. X    11,   3,  10,   6,   9,   8,   7,  10,   5,  11,
  264. X     2,  12,  -1,  12,  -4,  11,  -6,  10,  -8,   8,
  265. X    -9,   6, -10,   3, -10,   0,  -9,  -3,  -8,  -5,
  266. X    -6,  -7,  -4,  -8,  -1,  -9,   2,  -9,   5,  -8,
  267. X     7,  -7,   8,  -6};
  268. X
  269. Xstatic char c34[] = {
  270. X       8,  -9,   9,
  271. X     0,  12,  -8,  -9,  31,  31,
  272. X     0,  12,   8,  -9,  31,  31,  -6,  -4,   6,  -4};
  273. X
  274. Xstatic char c35[] = {
  275. X      23, -11,  10,
  276. X    -7,  12,  -7,  -9,  31,  31,
  277. X    -7,  12,   2,  12,   5,  11,   6,  10,   7,   8,
  278. X     7,   6,   6,   4,   5,   3,   2,   2,  31,  31,
  279. X    -7,   2,   2,   2,   5,   1,   6,   0,   7,  -2,
  280. X     7,  -5,   6,  -7,   5,  -8,   2,  -9,  -7,  -9};
  281. X
  282. Xstatic char c36[] = {
  283. X      18, -10,  11,
  284. X     8,   7,   7,   9,   5,  11,
  285. X     3,  12,  -1,  12,  -3,  11,  -5,   9,  -6,   7,
  286. X    -7,   4,  -7,  -1,  -6,  -4,  -5,  -6,  -3,  -8,
  287. X    -1,  -9,   3,  -9,   5,  -8,   7,  -6,   8,  -4};
  288. X
  289. Xstatic char c37[] = {
  290. X      15, -11,  10,
  291. X    -7,  12,  -7,  -9,  31,  31,
  292. X    -7,  12,   0,  12,   3,  11,   5,   9,   6,   7,
  293. X     7,   4,   7,  -1,   6,  -4,   5,  -6,   3,  -8,
  294. X     0,  -9,  -7,  -9};
  295. X
  296. Xstatic char c38[] = {
  297. X      11, -10,   9,
  298. X    -6,  12,  -6,  -9,  31,  31,
  299. X    -6,  12,   7,  12,  31,  31,  -6,   2,   2,   2,
  300. X    31,  31,  -6,  -9,   7,  -9};
  301. X
  302. Xstatic char c39[] = {
  303. X       8, -10,   8,
  304. X    -6,  12,  -6,  -9,  31,  31,
  305. X    -6,  12,   7,  12,  31,  31,  -6,   2,   2,   2};
  306. X
  307. Xstatic char c40[] = {
  308. X      22, -10,  11,
  309. X     8,   7,   7,   9,   5,  11,
  310. X     3,  12,  -1,  12,  -3,  11,  -5,   9,  -6,   7,
  311. X    -7,   4,  -7,  -1,  -6,  -4,  -5,  -6,  -3,  -8,
  312. X    -1,  -9,   3,  -9,   5,  -8,   7,  -6,   8,  -4,
  313. X     8,  -1,  31,  31,   3,  -1,   8,  -1};
  314. X
  315. Xstatic char c41[] = {
  316. X       8, -11,  11,
  317. X    -7,  12,  -7,  -9,  31,  31,
  318. X     7,  12,   7,  -9,  31,  31,  -7,   2,   7,   2};
  319. X
  320. Xstatic char c42[] = {
  321. X       8,  -6,   6,
  322. X     0,  12,   0,  -9,  31,  31,
  323. X    -3,  12,   3,  12,  31,  31,  -3,  -9,   3,  -9};
  324. X
  325. Xstatic char c43[] = {
  326. X      10,  -9,   8,
  327. X     4,  12,   4,  -4,   3,  -7,
  328. X     2,  -8,   0,  -9,  -2,  -9,  -4,  -8,  -5,  -7,
  329. X    -6,  -4,  -6,  -2};
  330. X
  331. Xstatic char c44[] = {
  332. X       8, -11,   9,
  333. X    -7,  12,  -7,  -9,  31,  31,
  334. X     7,  12,  -7,  -2,  31,  31,  -2,   3,   7,  -9};
  335. X
  336. Xstatic char c45[] = {
  337. X       5, -10,   7,
  338. X    -6,  12,  -6,  -9,  31,  31,
  339. X    -6,  -9,   6,  -9};
  340. X
  341. Xstatic char c46[] = {
  342. X      11, -12,  12,
  343. X    -8,  12,  -8,  -9,  31,  31,
  344. X    -8,  12,   0,  -9,  31,  31,   8,  12,   0,  -9,
  345. X    31,  31,   8,  12,   8,  -9};
  346. X
  347. Xstatic char c47[] = {
  348. X       8, -11,  11,
  349. X    -7,  12,  -7,  -9,  31,  31,
  350. X    -7,  12,   7,  -9,  31,  31,   7,  12,   7,  -9};
  351. X
  352. Xstatic char c48[] = {
  353. X      21, -11,  11,
  354. X    -2,  12,  -4,  11,  -6,   9,
  355. X    -7,   7,  -8,   4,  -8,  -1,  -7,  -4,  -6,  -6,
  356. X    -4,  -8,  -2,  -9,   2,  -9,   4,  -8,   6,  -6,
  357. X     7,  -4,   8,  -1,   8,   4,   7,   7,   6,   9,
  358. X     4,  11,   2,  12,  -2,  12};
  359. X
  360. Xstatic char c49[] = {
  361. X      13, -11,  10,
  362. X    -7,  12,  -7,  -9,  31,  31,
  363. X    -7,  12,   2,  12,   5,  11,   6,  10,   7,   8,
  364. X     7,   5,   6,   3,   5,   2,   2,   1,  -7,   1};
  365. X
  366. Xstatic char c50[] = {
  367. X      24, -11,  11,
  368. X    -2,  12,  -4,  11,  -6,   9,
  369. X    -7,   7,  -8,   4,  -8,  -1,  -7,  -4,  -6,  -6,
  370. X    -4,  -8,  -2,  -9,   2,  -9,   4,  -8,   6,  -6,
  371. X     7,  -4,   8,  -1,   8,   4,   7,   7,   6,   9,
  372. X     4,  11,   2,  12,  -2,  12,  31,  31,   1,  -5,
  373. X     7, -11};
  374. X
  375. Xstatic char c51[] = {
  376. X      16, -11,  10,
  377. X    -7,  12,  -7,  -9,  31,  31,
  378. X    -7,  12,   2,  12,   5,  11,   6,  10,   7,   8,
  379. X     7,   6,   6,   4,   5,   3,   2,   2,  -7,   2,
  380. X    31,  31,   0,   2,   7,  -9};
  381. X
  382. Xstatic char c52[] = {
  383. X      20, -10,  10,
  384. X     7,   9,   5,  11,   2,  12,
  385. X    -2,  12,  -5,  11,  -7,   9,  -7,   7,  -6,   5,
  386. X    -5,   4,  -3,   3,   3,   1,   5,   0,   6,  -1,
  387. X     7,  -3,   7,  -6,   5,  -8,   2,  -9,  -2,  -9,
  388. X    -5,  -8,  -7,  -6};
  389. X
  390. Xstatic char c53[] = {
  391. X       5,  -8,   8,
  392. X     0,  12,   0,  -9,  31,  31,
  393. X    -7,  12,   7,  12};
  394. X
  395. Xstatic char c54[] = {
  396. X      10, -11,  11,
  397. X    -7,  12,  -7,  -3,  -6,  -6,
  398. X    -4,  -8,  -1,  -9,   1,  -9,   4,  -8,   6,  -6,
  399. X     7,  -3,   7,  12};
  400. X
  401. Xstatic char c55[] = {
  402. X       5,  -9,   9,
  403. X    -8,  12,   0,  -9,  31,  31,
  404. X     8,  12,   0,  -9};
  405. X
  406. Xstatic char c56[] = {
  407. X      11, -12,  12,
  408. X    1   -10,  12,  -5,  -9,  31,  31,
  409. X     0,  12,  -5,  -9,  31,  31,   0,  12,   5,  -9,
  410. X    31,  31,  10,  12,   5,  -9};
  411. X
  412. Xstatic char c57[] = {
  413. X       5, -10,  10,
  414. X    -7,  12,   7,  -9,  31,  31,
  415. X     7,  12,  -7,  -9};
  416. X
  417. Xstatic char c58[] = {
  418. X       6,  -9,   9,
  419. X    -8,  12,   0,   2,   0,  -9,
  420. X    31,  31,   8,  12,   0,   2};
  421. X
  422. Xstatic char c59[] = {
  423. X       8, -10,  10,
  424. X     7,  12,  -7,  -9,  31,  31,
  425. X    -7,  12,   7,  12,  31,  31,  -7,  -9,   7,  -9};
  426. X
  427. Xstatic char c60[] = {
  428. X       8,  -7,   7,
  429. X    -3,  16,  -3, -16,  31,  31,
  430. X    -3,  16,   4,  16,
  431. X    31,  31,  -3, -16,   4, -16};
  432. X
  433. Xstatic char c61[] = {
  434. X       2, -11,  11,
  435. X    -9,  16,   9, -16};
  436. X
  437. Xstatic char c62[] = {
  438. X       8,  -7,   7,
  439. X     3,  16,   3, -16,  31,  31,  -4,  16,   3,  16,
  440. X    31,  31,  -4, -16,   3, -16};
  441. X
  442. Xstatic char c63[] = {
  443. X       3, -11,  11,
  444. X    1  -8, -2, 0, 3, 8, -2};
  445. X
  446. Xstatic char c64[] = {
  447. X       2, -12,  12,
  448. X    1  -9, -12, 9, -12};
  449. X
  450. Xstatic char c65[] = {
  451. X       2,  -6,   6,
  452. X    1  -2, 12, 3, 6};
  453. X
  454. Xstatic char c66[] = {
  455. X      17,  -9,  10,
  456. X     6,   5,   6,  -9,  31,  31,
  457. X     6,   2,   4,   4,   2,   5,  -1,   5,  -3,   4,
  458. X    -5,   2,  -6,  -1,  -6,  -3,  -5,  -6,  -3,  -8,
  459. X    -1,  -9,   2,  -9,   4,  -8,   6,  -6};
  460. X
  461. Xstatic char c67[] = {
  462. X      17, -10,   9,
  463. X    -6,  12,  -6,  -9,  31,  31,
  464. X    -6,   2,  -4,   4,  -2,   5,   1,   5,   3,   4,
  465. X     5,   2,   6,  -1,   6,  -3,   5,  -6,   3,  -8,
  466. X     1,  -9,  -2,  -9,  -4,  -8,  -6,  -6};
  467. X
  468. Xstatic char c68[] = {
  469. X      14,  -9,   9,
  470. X     6,   2,   4,   4,   2,   5,
  471. X    -1,   5,  -3,   4,  -5,   2,  -6,  -1,  -6,  -3,
  472. X    -5,  -6,  -3,  -8,  -1,  -9,   2,  -9,   4,  -8,
  473. X     6,  -6};
  474. X
  475. Xstatic char c69[] = {
  476. X      17,  -9,  10,
  477. X     6,  12,   6,  -9,  31,  31,
  478. X     6,   2,   4,   4,   2,   5,  -1,   5,  -3,   4,
  479. X    -5,   2,  -6,  -1,  -6,  -3,  -5,  -6,  -3,  -8,
  480. X    -1,  -9,   2,  -9,   4,  -8,   6,  -6};
  481. X
  482. Xstatic char c70[] = {
  483. X      17,  -9,   9,
  484. X    -6,  -1,   6,  -1,   6,   1,
  485. X     5,   3,   4,   4,   2,   5,  -1,   5,  -3,   4,
  486. X    -5,   2,  -6,  -1,  -6,  -3,  -5,  -6,  -3,  -8,
  487. X    -1,  -9,   2,  -9,   4,  -8,   6,  -6};
  488. X
  489. Xstatic char c71[] = {
  490. X       8,  -5,   7,
  491. X     5,  12,   3,  12,   1,  11,
  492. X     0,   8,   0,  -9,  31,  31,  -4,   5,   4,   5};
  493. X
  494. Xstatic char c72[] = {
  495. X      22,  -9,  10,
  496. X     6,   5,   6, -11,   5, -14,
  497. X     4, -15,   2, -16,  -1, -16,  -3, -15,  31,  31,
  498. X     6,   2,   4,   4,   2,   5,  -1,   5,  -3,   4,
  499. X    -5,   2,  -6,  -1,  -6,  -3,  -5,  -6,  -3,  -8,
  500. X    -1,  -9,   2,  -9,   4,  -8,   6,  -6};
  501. X
  502. Xstatic char c73[] = {
  503. X      10,  -9,  10,
  504. X    -5,  12,  -5,  -9,  31,  31,
  505. X    -5,   1,  -2,   4,   0,   5,   3,   5,   5,   4,
  506. X     6,   1,   6,  -9};
  507. X
  508. Xstatic char c74[] = {
  509. X       8,  -4,   4,
  510. X    -1,  12,   0,  11,   1,  12,
  511. X     0,  13,  -1,  12,  31,  31,   0,   5,   0,  -9};
  512. X
  513. Xstatic char c75[] = {
  514. X      11,  -5,   5,
  515. X     0,  12,   1,  11,   2,  12,
  516. X     1,  13,   0,  12,  31,  31,   1,   5,   1, -12,
  517. X     0, -15,  -2, -16,  -4, -16};
  518. X
  519. Xstatic char c76[] = {
  520. X       8,  -9,   8,
  521. X    -5,  12,  -5,  -9,  31,  31,
  522. X     5,   5,  -5,  -5,  31,  31,  -1,  -1,   6,  -9};
  523. X
  524. Xstatic char c77[] = {
  525. X       2,  -4,   4,
  526. X     0,  12,   0,  -9};
  527. X
  528. Xstatic char c78[] = {
  529. X      18, -15,  15,
  530. X    -11,   5, -11,  -9,  31,  31,
  531. X    -11,   1,  -8,   4,  -6,   5,  -3,   5,  -1,   4,
  532. X     0,   1,   0,  -9,  31,  31,   0,   1,   3,   4,
  533. X     5,   5,   8,   5,  10,   4,  11,   1,  11,  -9};
  534. X
  535. Xstatic char c79[] = {
  536. X      10,  -9,  10,
  537. X    -5,   5,  -5,  -9,  31,  31,
  538. X    -5,   1,  -2,   4,   0,   5,   3,   5,   5,   4,
  539. X     6,   1,   6,  -9};
  540. X
  541. Xstatic char c80[] = {
  542. X      17,  -9,  10,
  543. X    -1,   5,  -3,   4,  -5,   2,
  544. X    -6,  -1,  -6,  -3,  -5,  -6,  -3,  -8,  -1,  -9,
  545. X     2,  -9,   4,  -8,   6,  -6,   7,  -3,   7,  -1,
  546. X     6,   2,   4,   4,   2,   5,  -1,   5};
  547. X
  548. Xstatic char c81[] = {
  549. X      17, -10,   9,
  550. X    -6,   5,  -6, -16,  31,  31,
  551. X    -6,   2,  -4,   4,  -2,   5,   1,   5,   3,   4,
  552. X     5,   2,   6,  -1,   6,  -3,   5,  -6,   3,  -8,
  553. X     1,  -9,  -2,  -9,  -4,  -8,  -6,  -6,};
  554. X
  555. Xstatic char c82[] = {
  556. X      17,  -9,  10,
  557. X     6,   5,   6, -16,  31,  31,
  558. X     6,   2,   4,   4,   2,   5,  -1,   5,  -3,   4,
  559. X    -5,   2,  -6,  -1,  -6,  -3,  -5,  -6,  -3,  -8,
  560. X    -1,  -9,   2,  -9,   4,  -8,   6,  -6};
  561. X
  562. Xstatic char c83[] = {
  563. X       8,  -7,   7,
  564. X    -3,   5,  -3,  -9,  31,  31,
  565. X    -3,  -1,  -2,   2,   0,   4,   2,   5,   5,   5};
  566. X
  567. Xstatic char c84[] = {
  568. X      17,  -8,   9,
  569. X     6,   2,   5,   4,   2,   5,
  570. X    -1,   5,  -4,   4,  -5,   2,  -4,   0,  -2,  -1,
  571. X     3,  -2,   5,  -3,   6,  -5,   6,  -6,   5,  -8,
  572. X     2,  -9,  -1,  -9,  -4,  -8,  -5,  -6};
  573. X
  574. Xstatic char c85[] = {
  575. X       8,  -5,   7,
  576. X     0,  12,   0,  -5,   1,  -8,
  577. X     3,  -9,   5,  -9,  31,  31,  -4,   5,   4,   5};
  578. X
  579. Xstatic char c86[] = {
  580. X      10,  -9,  10,
  581. X    -5,   5,  -5,  -5,  -4,  -8,
  582. X    -2,  -9,   1,  -9,   3,  -8,   6,  -5,  31,  31,
  583. X     6,   5,   6,  -9};
  584. X
  585. Xstatic char c87[] = {
  586. X       5,  -8,   8,
  587. X    -6,   5,   0,  -9,  31,  31,
  588. X     6,   5,   0,  -9};
  589. X
  590. Xstatic char c88[] = {
  591. X      11, -11,  11,
  592. X    -8,   5,  -4,  -9,  31,  31,
  593. X     0,   5,  -4,  -9,  31,  31,   0,   5,   4,  -9,
  594. X    31,  31,   8,   5,   4,  -9};
  595. X
  596. Xstatic char c89[] = {
  597. X       5,  -9,   9,
  598. X    -6,   5,   6,  -9,  31,  31,
  599. X     6,   5,  -6,  -9};
  600. X
  601. Xstatic char c90[] = {
  602. X       9,  -8,   8,
  603. X    -6,   5,   0,  -9,  31,  31,
  604. X     6,   5,   0,  -9,  -2, -13,  -4, -15,  -6, -16,
  605. X    -7, -16};
  606. X
  607. Xstatic char c91[] = {
  608. X       8,  -9,   9,
  609. X     6,   5,  -6,  -9,  31,  31,
  610. X    -6,   5,   6,   5,  31,  31,  -6,  -9,   6,  -9};
  611. X
  612. Xstatic char c92[] = {
  613. X      17,  -7,   9,
  614. X    2, 16, -1, 13, -2, 10, -2, 8, -1, 5, 2, 2, 31, 31,
  615. X    2, 2, -1, 0, 2, -2, 31, 31,
  616. X    2, -2, -1, -5, -2, -8, -2, -10, -1, -13, 2, -16};
  617. X
  618. Xstatic char c93[] = {
  619. X       2,  -4,   4,
  620. X    0, 16, 0, -16};
  621. X
  622. Xstatic char c94[] = {
  623. X      17,  -7,   9,
  624. X    -2, 16, 1, 13, 2, 10, 2, 8, 1, 5, -2, 2, 31, 31,
  625. X    -2, 2, 1, 0, -2, -2, 31, 31,
  626. X    -2, -2, 1, -5, 2, -8, 2, -10, 1, -13, -2, -16};
  627. X
  628. Xstatic char c95[] = {
  629. X      11, -12,  14,
  630. X    -9, -3, -9, -1, -8, 2, -6, 3, -4, 3, -2, 2, 2, -1, 4, -2,
  631. X    6, -2, 8, -1, 9, 1};
  632. X
  633. Xstatic char c96[] = {
  634. X       4, -10,  10,
  635. X    -8, -9, 0, 12, 8, -9, -8, -9};
  636. X
  637. Xstatic char c97[] = {                /* ground */
  638. X       8,   0,   4,
  639. X       0,-5,0,5,31,31,2,-3,2,3,31,31,4,-1,4,1};
  640. X
  641. Xstatic char c98[] = {                /* vertical bar */
  642. X       2,   0,   3,
  643. X       0,-5,0,5 };
  644. X
  645. Xstatic char c99[] = {                /* chip */
  646. X       9,   0,   8,
  647. X       0,-8,0,8,3,8,3,6,5,6,5,8,8,8,8,-8,0,-8 };
  648. X
  649. Xstatic char c100[] = {                /* big circle */
  650. X      13,   0,  16,
  651. X      0,0,1,4,4,7,8,8,12,7,15,4,16,0,
  652. X      15,-4,12,-7,8,-8,4,-7,1,-4,0,0 };
  653. X
  654. Xstatic char c101[] = {                /* arrowtail > */
  655. X       3,   0,   5,
  656. X       0,-4,5,0,0,4 };
  657. X
  658. Xstatic char c102[] = {                /* - -  */
  659. X       5,   0,  15,
  660. X       0,0,5,0,31,31,10,0,15,0 };
  661. X
  662. Xstatic char c103[] = {                /* large curve ) */
  663. X       6,   -1,   3,
  664. X       -1,8,0,6,1,2,1,-2,0,-6,-1,-8 };
  665. X
  666. Xstatic char c104[] = {                /* centerline --- - */
  667. X       5,   0,  20,
  668. X       0,0,13,0,31,31,16,0,20,0 };
  669. X
  670. Xstatic char c105[] = {                /* inverter */
  671. X       4,   0,   7,
  672. X       0,-5,7,0,0,5,0,-5 };
  673. X
  674. Xstatic char c106[] = {                /* resistor */
  675. X       9,   0,  20,
  676. X       0,0,2,0,4,3,7,-3,10,3,13,-3,16,3,18,0,20,0 };
  677. X
  678. Xstatic char c107[] = {                /* transistor */
  679. X       9,   0,   6,
  680. X       0,-4,0,4,31,31,6,-8,6,-6,2,-6,2,6,6,6,6,8 };
  681. X
  682. Xstatic char c108[] = {                /* arrowhead */
  683. X       6,   0,   5,
  684. X       0,0,5,0,31,31,0,-4,5,0,0,4 };
  685. X
  686. Xstatic char c109[] = {                /* or gate */
  687. X      14,  -1,  16,
  688. X      -1,-8,7,-7,11,-5,14,-3,16,0,14,3,11,5,7,7,-1,8,0,6,1,2,1,-2,
  689. X      0,-6,-1,-8 };
  690. X
  691. Xstatic char c110[] = {                /* and gate */
  692. X      10,   0,  15,
  693. X      0,-8,8,-8,11,-7,14,-4,15,0,14,4,11,7,8,8,0,8,0,-8 };
  694. X
  695. Xstatic char c111[] = {                /* not symbol o */
  696. X       9,   0,   4,
  697. X       0,-1,1,-2,3,-2,4,-1,4,1,3,2,1,2,0,1,0,-1 };
  698. X
  699. Xstatic char c112[] = {                /*  wire connect dot */
  700. X       5,  0,  0,
  701. X       -1,-1,1,-1,1,1,-1,1,-1,-1 };
  702. X
  703. Xstatic char *p[] = { 
  704. X    c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
  705. X    c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24,
  706. X    c25, c26, c27, c28, c29, c30, c31, c32, c33, c34, c35, c36,
  707. X    c37, c38, c39, c40, c41, c42, c43, c44, c45, c46, c47, c48,
  708. X    c49, c50, c51, c52, c53, c54, c55, c56, c57, c58, c59, c60,
  709. X    c61, c62, c63, c64, c65, c66, c67, c68, c69, c70, c71, c72,
  710. X    c73, c74, c75, c76, c77, c78, c79, c80, c81, c82, c83, c84,
  711. X    c85, c86, c87, c88, c89, c90, c91, c92, c93, c94, c95, c96,
  712. X    c97, c98, c99, c100,c101,c102,c103,c104,c105,c106,c107,c108,
  713. X    c109,c110,c111,c112};
  714. X/*--------------------------------*/
  715. X    i = ch-32;
  716. X    c = error_char;
  717. X    if (i >= 0 && i <113) c = p[i];
  718. X    *npts = ( *c++) << 1;        /* convert pt count to coord count*/
  719. X    *min = *c++;            /* extent of char, in char coords*/
  720. X    *max = *c++;
  721. X    for (i=0; i<*npts; i++) *pts++ = *c++;
  722. X}
  723. END_OF_FILE
  724. # end of 'lib/sfont.c'
  725. fi
  726. if test -f 'src/subs.c' -a "${1}" != "-c" ; then 
  727.   echo shar: Will not clobber existing file \"'src/subs.c'\"
  728. else
  729. echo shar: Extracting \"'src/subs.c'\" \(16545 characters\)
  730. sed "s/^X//" >'src/subs.c' <<'END_OF_FILE'
  731. X/*                        Copyright (c) 1987 Bellcore
  732. X *                            All Rights Reserved
  733. X *       Permission is granted to copy or use this program, EXCEPT that it
  734. X *       may not be sold for profit, the copyright notice must be reproduced
  735. X *       on copies, and credit should be given to Bellcore where it is due.
  736. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  737. X */
  738. X/*    $Header: subs.c,v 4.6 88/08/12 07:41:12 sau Exp $
  739. X    $Source: /tmp/mgrsrc/src/RCS/subs.c,v $
  740. X*/
  741. Xstatic char    RCSid_[] = "$Source: /tmp/mgrsrc/src/RCS/subs.c,v $$Revision: 4.6 $";
  742. X
  743. X/* misc window and screen mangement routines */
  744. X
  745. X#include "bitmap.h"
  746. X#include <stdio.h>
  747. X#include <sys/ioctl.h>
  748. X#include <sys/signal.h>
  749. X#include "font.h"
  750. X#include "defs.h"
  751. X#include "event.h"
  752. X#include "window.h"
  753. X
  754. X/*****************************************************************************
  755. X *    deactivate all windows covered by win (used for new window creation)
  756. X */
  757. X
  758. Xset_covered(check)
  759. Xregister WINDOW *check;            /* window to check covering against */
  760. X   {
  761. X   register WINDOW *win;
  762. X
  763. X   for(win=active;win != (WINDOW *) 0;win=win->next)
  764. X       if (win!=check && intersect(win,check) && W(flags)&W_ACTIVE) {
  765. X          save_win(win);
  766. X          do_event(EVENT_COVERED,win,E_MAIN);
  767. X          W(flags) &= ~W_ACTIVE;
  768. X          if (!(W(flags)&W_LOOK))
  769. X             mask &= ~(1<<W(to_fd));
  770. X#ifdef DEBUG
  771. X          dprintf(o)(stderr,"\t%s covers %s\r\n",check->tty,W(tty));
  772. X#endif
  773. X          } 
  774. X   }
  775. X
  776. X/*****************************************************************************
  777. X *    find and activate all windows previously covered by win
  778. X */
  779. X
  780. Xun_covered()
  781. X   {
  782. X   register WINDOW *win,*check;
  783. X   register int cover;
  784. X   
  785. X   for(win=active;win != (WINDOW *) 0;win=W(next)) {
  786. X#ifdef DEBUG
  787. X      dprintf(U)(stderr,"    invalidate cliplist: %s)\r\n",W(tty));
  788. X      dprintf(o)(stderr,"    un_cover: %s)\n",W(tty));
  789. X#endif
  790. X      for(cover=0,check=active;check!=win && cover==0;check=check->next)
  791. X         if (intersect(win,check)) cover=1;
  792. X
  793. X      if (cover && W(flags)&W_ACTIVE) {
  794. X          do_event(EVENT_COVERED,win,E_MAIN);
  795. X          W(flags) &= ~W_ACTIVE;
  796. X          if (!(W(flags)&W_LOOK))
  797. X             mask &= ~(1<<W(to_fd));
  798. X#ifdef DEBUG
  799. X          dprintf(o)(stderr,"becoming inactive (covered by %s)\r\n",check->tty);
  800. X#endif
  801. X          }
  802. X      else if (!cover && !(W(flags)&W_ACTIVE)) {
  803. X          do_event(EVENT_UNCOVERED,win,E_MAIN);
  804. X          W(flags) |= W_ACTIVE;
  805. X          if (!(W(flags)&W_DIED))
  806. X             mask |= (1<<W(to_fd));
  807. X#ifdef DEBUG
  808. X          dprintf(o)(stderr,"becoming active\r\n");
  809. X#endif
  810. X          }
  811. X      else if (cover && !(W(flags)&W_ACTIVE))  {
  812. X#ifdef DEBUG
  813. X         dprintf(o)(stderr,"remains inactive (covered by %s)\r\n",check->tty);
  814. X#endif
  815. X         ;
  816. X         }
  817. X      else if (!cover && W(flags)&W_ACTIVE) {
  818. X#ifdef DEBUG
  819. X         dprintf(o)(stderr,"remains active\r\n");
  820. X#endif
  821. X         ;
  822. X         }
  823. X      else 
  824. X         if( debug )
  825. X        fprintf(stderr,"%s: unknown covering state\r\n",W(tty));
  826. X      }
  827. X   }
  828. X
  829. X/*****************************************************************************
  830. X *    bring a window to the top
  831. X */
  832. X
  833. Xexpose(win)
  834. Xregister WINDOW *win;            /* window to expose */
  835. X   {
  836. X#ifdef DEBUG
  837. X   dprintf(o)(stderr,"exposing %s\r\n",W(tty));
  838. X#endif
  839. X   
  840. X   /* reorder windows */
  841. X
  842. X   if (win == active)
  843. X      return(0);
  844. X
  845. X   W(prev)->next = W(next);
  846. X   if (W(next))
  847. X      W(next)->prev = W(prev);
  848. X   else
  849. X      ACTIVE(prev) = W(prev);
  850. X
  851. X   W(prev) = ACTIVE(prev);
  852. X   W(next) = active;
  853. X
  854. X   ACTIVE(prev) = win;
  855. X   active = win;
  856. X
  857. X   if (!(W(flags)&W_ACTIVE)) {
  858. X      for(win=active->next;win!=(WINDOW *) 0;win=W(next))
  859. X         if (W(flags)&W_ACTIVE && intersect(active,win))
  860. X            save_win(win);
  861. X   
  862. X      restore_win(active);
  863. X   
  864. X      clip_bad(active);    /* invalidate clip lists */
  865. X      un_covered();
  866. X      }
  867. X#ifdef DEBUG
  868. X   else
  869. X      dprintf(o)(stderr,"expose: %s already active (0%o)\r\n",
  870. X              ACTIVE(tty),ACTIVE(flags));
  871. X#endif
  872. X   }
  873. X   
  874. X   
  875. X/*****************************************************************************
  876. X *    move a window at the bottom of window list
  877. X */
  878. X
  879. Xint
  880. Xbury(win)
  881. Xregister WINDOW *win;            /* window to bury */
  882. X   {
  883. X#ifdef DEBUG
  884. X   dprintf(o)(stderr,"burying %s\r\n",W(tty));
  885. X#endif
  886. X   if (!win || !W(next))
  887. X      return(0);
  888. X
  889. X   if (win == active)
  890. X      active = W(next);
  891. X
  892. X   W(prev)->next = W(next);
  893. X   W(next)->prev = W(prev);
  894. X
  895. X   W(prev) = ACTIVE(prev);
  896. X   ACTIVE(prev)->next = win;
  897. X
  898. X   ACTIVE(prev) = win;
  899. X   W(next) = (WINDOW *) 0;
  900. X   return(1);
  901. X   }
  902. X
  903. X/*****************************************************************************
  904. X *    bury a window at the bottom of the screen
  905. X */
  906. X
  907. Xhide(win)
  908. Xregister WINDOW *win;            /* window to hide */
  909. X   {
  910. X#ifdef DEBUG
  911. X   dprintf(o)(stderr,"hiding %s\r\n",W(tty));
  912. X#endif
  913. X   if (bury(win)==0)
  914. X      return(0);
  915. X   save_win(win);
  916. X   repair(win);
  917. X   clip_bad(active);    /* invalidate clip lists */
  918. X   }
  919. X
  920. X/*****************************************************************************
  921. X *    repair effects of buried window
  922. X */
  923. X
  924. Xint
  925. Xrepair(clip)
  926. Xregister WINDOW *clip;            /* window causing repairs */
  927. X   {
  928. X   register WINDOW *win;
  929. X#ifdef NOCLIP
  930. X   for(win=ACTIVE(prev)->prev;win!=active;win=W(prev))
  931. X      if (!alone(win)) restore_win(win);
  932. X   restore_win(win);
  933. X#else
  934. X   for(win=clip->prev;win!=active;win=W(prev))
  935. X       if (intersect(clip,win))
  936. X          clip_win(win,clip);
  937. X    if (clip!= active && intersect(clip,active))
  938. X       clip_win(active,clip);
  939. X#endif
  940. X   un_covered();
  941. X   }
  942. X   
  943. X/*****************************************************************************
  944. X *    save a pixel image of the window
  945. X */
  946. X
  947. Xsave_win(win)
  948. Xregister WINDOW *win;            /* window to save */
  949. X   {
  950. X#ifdef DEBUG
  951. X   dprintf(o)(stderr,"\t\t  saving %s\r\n",W(tty));
  952. X#endif
  953. X   if (W(save) == (BITMAP *) 0) {
  954. X      W(save) = bit_alloc(BIT_WIDE(W(border)),BIT_HIGH(W(border)),
  955. X                          NULL_DATA,DEPTH);
  956. X      }
  957. X   else if (BIT_WIDE(W(save)) != BIT_WIDE(W(border))  ||
  958. X            BIT_HIGH(W(save)) != BIT_HIGH(W(border))) {
  959. X#ifdef DEBUG
  960. X      dprintf(o)(stderr,"Saved window %s mismatch\r\n",W(tty));
  961. X#endif
  962. X      bit_destroy(W(save));
  963. X      W(save) = bit_alloc(BIT_WIDE(W(border)),BIT_HIGH(W(border)),
  964. X                          NULL_DATA,DEPTH);
  965. X      }
  966. X
  967. X   bit_blit(W(save),0,0,BIT_WIDE(W(border)),BIT_HIGH(W(border)),
  968. X          BIT_SRC,W(border),0,0);
  969. X   }
  970. X
  971. X/*****************************************************************************
  972. X *    partially restore a previously saved pixel image of the window 
  973. X */
  974. X
  975. X#define C(x)    (clip->x)
  976. X#ifndef Max
  977. X#define Max(x,y)        ((x)>(y)?(x):(y))
  978. X#endif
  979. X#ifndef Min
  980. X#define Min(x,y)        ((x)>(y)?(y):(x))
  981. X#endif
  982. X
  983. Xclip_win(win,clip)
  984. Xregister WINDOW *win;            /* window to restore to screen */
  985. Xregister WINDOW *clip;            /* clip window */
  986. X   {
  987. X   int x0 = Max(W(x0),C(x0)) - W(x0);
  988. X   int y0 = Max(W(y0),C(y0)) - W(y0);
  989. X   int x1 = Min(W(x0)+BIT_WIDE(W(border)),C(x0)+BIT_WIDE(C(border))) - W(x0);
  990. X   int y1 = Min(W(y0)+BIT_HIGH(W(border)),C(y0)+BIT_HIGH(C(border))) - W(y0);
  991. X
  992. X   if (W(save) != (BITMAP *) 0) {
  993. X
  994. X/*    ******* look at clipping region **********
  995. X      bit_blit(W(border),x0,y0,x1-x0,y1-y0 ,
  996. X               BIT_NOT(BIT_DST),W(save),x0,y0);
  997. X      getchar();
  998. Xend of debug */
  999. X
  1000. X      bit_blit(W(border),x0,y0,x1-x0,y1-y0,
  1001. X               BIT_SRC,W(save),x0,y0);
  1002. X      }
  1003. X   else
  1004. X      if( debug )
  1005. X     fprintf(stderr,"clip: can't restore %s\r\n",W(tty));
  1006. X#ifdef DEBUG
  1007. X   dprintf(o)(stderr,"\t\t  restore %s (clip to %s)\r\n",W(tty),C(tty));
  1008. X#endif
  1009. X   }
  1010. X
  1011. X/*****************************************************************************
  1012. X *    restore a previously saved pixel image of the window 
  1013. X */
  1014. X
  1015. Xrestore_win(win)
  1016. Xregister WINDOW *win;            /* window to restore to screen */
  1017. X   {
  1018. X   if (W(save) != (BITMAP *) 0)
  1019. X   bit_blit(W(border),0,0,BIT_WIDE(W(border)),BIT_HIGH(W(border)),
  1020. X          BIT_SRC,W(save),0,0);
  1021. X#ifdef DEBUG
  1022. X   dprintf(o)(stderr,"\t\t  restoring %s\r\n",W(tty));
  1023. X#endif
  1024. X   }
  1025. X
  1026. X/*****************************************************************************
  1027. X *    move the mouse, keep exclusive control 
  1028. X *    "how" specifies how we recognize completion:
  1029. X *        how == 0:    all buttons were up at start of action,
  1030. X *                any button pushed down completes the action.
  1031. X *        how != 0:    some button was down at start of action,
  1032. X *                all buttons released completes the action.
  1033. X */
  1034. X
  1035. Xint
  1036. Xmove_mouse(screen,mouse,x,y,how)
  1037. XBITMAP *screen;
  1038. Xint mouse, *x, *y;
  1039. Xint how;
  1040. X   {
  1041. X   register int mx = *x, my = *y;
  1042. X   register int button = 0;
  1043. X   int dx,dy;
  1044. X   MOUSE_ON(mx,my);
  1045. X   do {
  1046. X      button=mouse_get(mouse,&dx,&dy);
  1047. X      MOUSE_OFF(mx,my);
  1048. X      mx += dx;
  1049. X      my -= dy;
  1050. X      mx = BETWEEN(0,mx,BIT_WIDE(screen)); 
  1051. X      my = BETWEEN(0,my,BIT_HIGH(screen)); 
  1052. X      MOUSE_ON(mx,my);
  1053. X      }
  1054. X   while (how ? button!= 0 : button==0);
  1055. X   if( how )
  1056. X    do_button( 0 );
  1057. X   MOUSE_OFF(mx,my);
  1058. X   *x = mx;
  1059. X   *y = my;
  1060. X   return(button);
  1061. X   }
  1062. X
  1063. X/*****************************************************************************
  1064. X *    parse a line into fields
  1065. X */
  1066. X
  1067. X#ifdef SYSV
  1068. X#define index        strchr
  1069. X#endif
  1070. X
  1071. X#define iswhite(x)    (index(" \t",x))
  1072. X
  1073. Xint
  1074. Xparse(line,fields)
  1075. Xregister char *line;
  1076. Xregister char **fields;
  1077. X   {
  1078. X   char *index();
  1079. X   int inword = 0;
  1080. X   int count = 0;
  1081. X   char *start;
  1082. X   register char c;
  1083. X
  1084. X   for(start = line;(c = *line) && c != '\n';line++)
  1085. X      if (inword && iswhite(c)) {
  1086. X         inword = 0;
  1087. X         *line = '\0';
  1088. X         *fields++ = start;
  1089. X         count++;
  1090. X         }
  1091. X      else if (!inword && !iswhite(c)) {
  1092. X         start = line;
  1093. X         inword = 1;
  1094. X         }
  1095. X
  1096. X   if (inword) {
  1097. X      *fields++ = start;
  1098. X      count++;
  1099. X      if (c == '\n')
  1100. X         *line = '\0';
  1101. X      }
  1102. X   *fields = (char *) 0;
  1103. X   return(count);
  1104. X   }
  1105. X
  1106. X/*****************************************************************************
  1107. X *    parse a string to interpret \'s
  1108. X */
  1109. X
  1110. Xchar *
  1111. Xtrans(s)
  1112. Xchar *s;
  1113. X   {
  1114. X   char *result = s;
  1115. X   register int i=0;
  1116. X   register char c;
  1117. X   register int got_slash=0;
  1118. X
  1119. X   while(c = *s++&0x7f) {
  1120. X      if (got_slash){
  1121. X         switch(c) {
  1122. X            case 'e':
  1123. X            case 'E': result[i++] = '\033'; break;
  1124. X            case 'n': result[i++] = '\n';   break;
  1125. X            case 'r': result[i++] = '\r';   break;
  1126. X            case 'b': result[i++] = '\b';   break;
  1127. X            case 'f': result[i++] = '\f';   break;
  1128. X            case 'g': result[i++] = '\007'; break;
  1129. X            case 's': result[i++] = ' ';    break;
  1130. X            case '\\': result[i++] = '\\';  break;
  1131. X            case 'M': result[i++] = *s++|0x80; break;
  1132. X            default:  result[i++] = c;      break;
  1133. X            }
  1134. X         got_slash = 0;
  1135. X         }
  1136. X      else if (c=='\\')
  1137. X         got_slash++;
  1138. X      else 
  1139. X         result[i++] = c;
  1140. X      } 
  1141. X   result[i] = '\0';
  1142. X   return(result);
  1143. X   }
  1144. X
  1145. X/* suspend MGR */
  1146. X
  1147. Xint suspend()
  1148. X   {
  1149. X#ifdef SIGSTOP
  1150. X   register WINDOW *win;
  1151. X
  1152. X   MOUSE_OFF(mousex,mousey);
  1153. X   sleep(1);    /* give the key time to go up */
  1154. X   set_kbd(0);    /* fix up keyboard modes */
  1155. X
  1156. X   for(win=active;win!=(WINDOW *) 0;win=win->next) {
  1157. X      killpg(W(pid),SIGSTOP);
  1158. X      if (W(flags)&W_ACTIVE)
  1159. X         save_win(win);
  1160. X      }
  1161. X
  1162. X   reset_tty(0);
  1163. X   kbd_reset();
  1164. X   close(mouse);
  1165. X   reset_tty(0);
  1166. X   fprintf(stderr,"\fmgr suspended ...\n");
  1167. X#ifdef WHO
  1168. X   restore_utmp(0,"");
  1169. X#endif
  1170. X
  1171. X   do_cmd( 's' );    /* do the suspention command */
  1172. X
  1173. X   /* courtesy DVW */
  1174. X   signal(SIGTSTP, SIG_DFL);
  1175. X   kill(0,SIGTSTP);            /* send stop signal to self */
  1176. X   sleep(1);                /* wait for CONT signal */
  1177. X   signal(SIGTSTP, catch);
  1178. X
  1179. X   do_cmd( 'r' );    /* do the resumption command */
  1180. X
  1181. X   if (set_kbd(1) != 0) {    /* reopen kbd (as 0) */
  1182. X      _quit();
  1183. X      fprintf(stderr,"Sorry, Can't reopen kbd\n");
  1184. X      exit(1);
  1185. X      }
  1186. X   mouse = mouse_reopen();
  1187. X   set_tty(0);
  1188. X   bell_on();    /* this resets the keyboard! */
  1189. X
  1190. X#ifdef WHO
  1191. X   save_utmp(ttyname(0));
  1192. X#endif
  1193. X   erase_win(screen,0,0);
  1194. X   if (active) {
  1195. X      for(win=ACTIVE(prev);win!=active;win=W(prev)) {
  1196. X         restore_win(win);
  1197. X         killpg(W(pid),SIGCONT);
  1198. X         }
  1199. X      restore_win(active);
  1200. X      killpg(ACTIVE(pid),SIGCONT);
  1201. X      }
  1202. X#endif
  1203. X   MOUSE_ON(mousex,mousey);
  1204. X   }
  1205. X
  1206. X/*    Get a font from font numbers.
  1207. X    Font numbers run 0 through MAXFONT;
  1208. X    Font 0 is the default font. */
  1209. X
  1210. Xstruct font *
  1211. XGet_font(fnt)
  1212. Xint fnt;                /* font number */
  1213. X   {
  1214. X   struct font *new, *get_font();
  1215. X   char buff[MAX_PATH];
  1216. X   char *name;
  1217. X
  1218. X   if (fnt<=0 || fnt>MAXFONT || fontlist[fnt-1] == (char *) 0)
  1219. X      return(font);
  1220. X
  1221. X   if (*fontlist[fnt-1] == '/') 
  1222. X      name = fontlist[fnt-1];
  1223. X   else {
  1224. X      sprintf(buff, "%s/%s", font_dir, fontlist[fnt-1]);
  1225. X      name = buff;
  1226. X      }
  1227. X   if ((new = get_font(name))==(struct font *)0)
  1228. X      new = font;
  1229. X   else
  1230. X      new->ident = fnt;
  1231. X   return(new);
  1232. X   }
  1233. X
  1234. X#ifdef ALIGN
  1235. X
  1236. X/* align a window so a byte boundary occurs somewhere insode the border */
  1237. X  
  1238. Xint
  1239. Xalignwin(screen,x,dx,slop)
  1240. Xregister BITMAP *screen;
  1241. Xregister int *x, *dx;
  1242. Xint slop;
  1243. X   {
  1244. X   register int adjust = (BIT_X(screen)+ *x) & 7;
  1245. X
  1246. X   if (adjust>0 && adjust<(8-slop)) {
  1247. X      *x -= adjust;
  1248. X#ifdef DEBUG
  1249. X      dprintf(A)(stderr,"Adjusting x by %d",adjust);
  1250. X#endif
  1251. X      }
  1252. X#ifdef DEBUG
  1253. X      dprintf(A)(stderr," at [%d/%d]\r\n",*x,(*x)&7);
  1254. X#endif
  1255. X
  1256. X   adjust = (adjust + *dx) &7;
  1257. X
  1258. X   if (adjust>slop) { 
  1259. X      *dx += 8-adjust;
  1260. X#ifdef DEBUG
  1261. X      dprintf(A)(stderr,"Adjusting dx by %d\r\n",8-adjust);
  1262. X#endif
  1263. X      }
  1264. X#ifdef DEBUG
  1265. X      dprintf(A)(stderr," at [%d/%d]\r\n",*x + *dx,(*x + *dx)&7);
  1266. X#endif
  1267. X   }
  1268. X#endif ALIGN
  1269. X
  1270. X/* look for and remove all references to a particular font */
  1271. X
  1272. Xint
  1273. Xfont_purge(gone)
  1274. Xregister struct font *gone;        /* invalid font pointer */
  1275. X   {
  1276. X   register WINDOW *win, *win2;
  1277. X   register int count=0;
  1278. X
  1279. X   /* re-reference current window font */
  1280. X
  1281. X   for(win=active;win != (WINDOW *) 0;win=win->next) {
  1282. X      if (W(font) == gone) {
  1283. X         W(font) = font;
  1284. X         count++;
  1285. X         }
  1286. X
  1287. X      /* now re-reference any stacked fonts */
  1288. X
  1289. X      for(win2=W(stack);win2 != (WINDOW *) 0;win2=win2->stack)
  1290. X         if (win2->font == gone) {
  1291. X            win2->font = font;
  1292. X            count++;
  1293. X            }
  1294. X      }
  1295. X   return(count);
  1296. X   }
  1297. X/*********************************************************************/
  1298. X
  1299. X/* make sure icon is valid */
  1300. X
  1301. Xint
  1302. Xcursor_ok(map,x,y)
  1303. XBITMAP *map;            /* cursor icon */
  1304. Xint x,y;                    /* starting coord */
  1305. X   {
  1306. X   if (map==BIT_NULL || BIT_WIDE(map) < 16+x  || BIT_HIGH(map) < 32+y)
  1307. X      return(0);
  1308. X   else                     /* we'll check more later */
  1309. X      return(1);
  1310. X   }
  1311. X
  1312. X
  1313. Xstatic int cursoron = 0;
  1314. X
  1315. Xcursor_on()
  1316. X{
  1317. X    if( !active ) {
  1318. X        cursoron = 0;
  1319. X        return;
  1320. X    }
  1321. X    if( cursoron )
  1322. X        return;
  1323. X    do_cursor(active);
  1324. X    cursoron = 1;
  1325. X}
  1326. X
  1327. Xcursor_off()
  1328. X{
  1329. X    if( !active ) {
  1330. X        cursoron = 0;
  1331. X        return;
  1332. X    }
  1333. X    if( !cursoron )
  1334. X        return;
  1335. X    cursoron = 0;
  1336. X    do_cursor(active);
  1337. X}
  1338. X
  1339. Xstatic int
  1340. Xdo_cursor(win)
  1341. XWINDOW *win;
  1342. X    {
  1343. X    switch(W(curs_type)) {
  1344. X        case CS_BLOCK:
  1345. X            bit_blit(W(window), W(x)+W(text.x),
  1346. X                W(y)+W(text.y)-W(font->head.high),
  1347. X                W(font->head.wide), W(font->head.high),
  1348. X                BIT_NOT(BIT_DST), 0, 0, 0);
  1349. X            break;
  1350. X        case CS_BOX:
  1351. X            bit_blit(W(window), W(x)+W(text.x),
  1352. X                W(y)+W(text.y)-W(font->head.high)+1,
  1353. X                W(font->head.wide), W(font->head.high)-2,
  1354. X                BIT_NOT(BIT_DST), 0, 0, 0);
  1355. X            bit_blit(W(window), W(x)+W(text.x)-2,
  1356. X                W(y)+W(text.y)-W(font->head.high)-1,
  1357. X                W(font->head.wide)+4, W(font->head.high)+2,
  1358. X                BIT_NOT(BIT_DST), 0, 0, 0);
  1359. X            break;
  1360. X        case CS_LEFT:
  1361. X            bit_blit(W(window), W(x)+W(text.x) - 1,
  1362. X                W(y)+W(text.y)-W(font->head.high),
  1363. X                2, W(font->head.high),
  1364. X                BIT_NOT(BIT_DST), 0, 0, 0);
  1365. X            break;
  1366. X        case CS_RIGHT:
  1367. X            bit_blit(W(window), W(x)+W(text.x)+W(font->head.wide)-1,
  1368. X                W(y)+W(text.y)-W(font->head.high),
  1369. X                2, W(font->head.high),
  1370. X                BIT_NOT(BIT_DST), 0, 0, 0);
  1371. X            break;
  1372. X        case CS_UNDER:
  1373. X            bit_blit(W(window), W(x)+W(text.x),
  1374. X                W(y)+W(text.y)-1,
  1375. X                W(font->head.wide), 2,
  1376. X                BIT_NOT(BIT_DST), 0, 0, 0);
  1377. X            break;
  1378. X        }
  1379. X    }
  1380. X
  1381. X/* system command - turn off root privaleges */
  1382. X
  1383. Xsystem(command)
  1384. Xchar *command;
  1385. X{
  1386. X        int status, pid, w;
  1387. X        register int (*istat)(), (*qstat)();
  1388. X
  1389. X    if (!command  ||  *command == '\0')
  1390. X        return(0);
  1391. X        if ((pid = vfork()) == 0) { /* does vfork work? */
  1392. X
  1393. X                /* make sure commands doesn't run as root */
  1394. X      
  1395. X                int uid = getuid();
  1396. X                int gid = getgid();
  1397. X                setreuid(uid,uid);
  1398. X                setregid(gid,gid);
  1399. X
  1400. X        close(0);
  1401. X        open("/dev/null",0);
  1402. X
  1403. X                execl("/bin/sh", "sh", "-c", command, 0);
  1404. X                _exit(127);
  1405. X        }
  1406. X        istat = signal(SIGINT, SIG_IGN);
  1407. X        qstat = signal(SIGQUIT, SIG_IGN);
  1408. X        while ((w = wait(&status)) != pid && w != -1)
  1409. X                ;
  1410. X        if (w == -1)
  1411. X                status = -1;
  1412. X        signal(SIGINT, istat);
  1413. X        signal(SIGQUIT, qstat);
  1414. X        return(status);
  1415. X}
  1416. END_OF_FILE
  1417. # end of 'src/subs.c'
  1418. fi
  1419. echo shar: End of archive 39 \(of 61\).
  1420. cp /dev/null ark39isdone
  1421. MISSING=""
  1422. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  1423.     21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 \
  1424.     38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 \
  1425.     55 56 57 58 59 60 61 ; do
  1426.     if test ! -f ark${I}isdone ; then
  1427.     MISSING="${MISSING} ${I}"
  1428.     fi
  1429. done
  1430. if test "${MISSING}" = "" ; then
  1431.     echo You have unpacked all 61 archives.
  1432.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1433. else
  1434.     echo You still need to unpack the following archives:
  1435.     echo "        " ${MISSING}
  1436. fi
  1437. ##  End of shell archive.
  1438. exit 0
  1439.